<template>
  <div>
    <div class="equipContainner1">
      <el-row :gutter="20" class="seachnav">
        <el-col :xs="7" :sm="6" :md="4" :lg="6" :xl="3" class="navHeight">
          <span><img :src="returandisabled" class="returandisabled"/></span>
          <span><img :src="message" class="equiplist"/></span>
          <!--<span @click="searchShow()"><img :src="searchinvalid" class="searchinvalid"/></span>-->
        </el-col>
        <el-col :xs="7" :sm="6" :md="18" :lg="18" :xl="21" class="con" >
          <p  class="seachContent">{{this.seachContent}}</p>
        </el-col>
      </el-row>
    </div>
    <div class="infoNav-containner">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane :label="'必要信息('+ this.needfulTotal +')'" name="first">
          <div class="viewContent">
            <neededMessage @cleanSuccess="resetFromChild" ref="needed"></neededMessage>
          </div>
        </el-tab-pane>
        <el-tab-pane :label="'告警('+ this.alarmTotal +')'" name="second">
          <div class="viewContent">
            <alarm-message @cleanSuccess="resetFromChild" ref="alarm"></alarm-message>
          </div>
        </el-tab-pane>
        <el-tab-pane :label="'预警('+ this.earlyWarningTotal +')'" name="third">
          <div class="viewContent">
            <warning-message ref="warning"></warning-message>
          </div>
        </el-tab-pane>
        <el-tab-pane :label="'到期('+ this.fittingsTotal +')'" name="forth">
          <div class="viewContent">
            <notification ref="notification"></notification>
          </div>
        </el-tab-pane>
        <!--<el-tab-pane :label="noticeTotal" name="fifth">-->
          <!--<div class="viewContent">-->
            <!--<station-message></station-message>-->
          <!--</div>-->
        <!--</el-tab-pane>-->
      </el-tabs>
    </div>
  </div>
</template>
<script>
  import axios from 'axios'
  import alarmMessage from './alarmMessage'
  import warningMessage from './warningMessage.vue'
  import notification from './notification.vue'
  import neededMessage from './neededMessage.vue'
  import stationMessage from './stationMessage.vue'
  import returandisabled from '@/assets/equipv2/returandisabled.png'
  import message from '@/assets/messageCenter/message.png'
  export default {
    components: { alarmMessage, warningMessage, notification, neededMessage, stationMessage },
    data() {
      return {
        // 顶端显示
        returandisabled,
        message,
        seachContent: '消息中心',
        activeName: 'first',
        // total
        alarmTotal: '',
        earlyWarningTotal: '',
        fittingsTotal: '',
        needfulTotal: '',
        noticeTotal: '',
        // 接口
        totalData: {
          access_token: localStorage.getItem('access_token'),
          type: 'remind_total'
        }
      }
    },
    mounted() {
      this.getTotal()
    },
    methods: {
      // 父组件接收值
      resetFromChild() {
        this.getTotal()
      },
      handleClick() {
        if (this.activeName === 'first') {
          this.$refs.needed.neededDataGet()
          this.$refs.alarm.intData()
        }
        if (this.activeName === 'second') {
          this.$refs.alarm.alarmDataGet()
          this.$refs.alarm.intData()
        }
        if (this.activeName === 'third') {
          this.$refs.warning.getWarning()
          this.$refs.alarm.intData()
        }
        if (this.activeName === 'forth') {
          this.$refs.notification.getFitting()
          this.$refs.alarm.intData()
        }
        this.getTotal()
      },
      // 警告
      getTotal() {
        axios.post('/remind', this.totalData, {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((res) => {
          this.alarmTotal = res.data.data.alarm_total
          this.earlyWarningTotal = res.data.data.early_warning_total
          this.fittingsTotal = res.data.data.fittings_total
          this.needfulTotal = res.data.data.needful_total
          this.noticeTotal = res.data.data.notice_total
          console.log(res)
        })
          .catch((error) => {
            // console.log(error)
          })
      }
    }
  }

</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  .equipContainner1 {
    width: 100%;
    /*min-height: 53vw;*/
    background-color: #EFEFEF;
    .seachnav {
      width: 60%;
      height: 50px;
      position: fixed;
      z-index: 2;
      top: 0;
      bottom: 0;
      line-height: 50px;
      padding-left: 20px;
      .navHeight {
        height: 60px;
        .returandisabled {
          vertical-align: -webkit-baseline-middle;
        }
        .equiplist {
          vertical-align: -webkit-baseline-middle;
          margin-left: 15px;
        }
      }
      .con {
        width: 85%;
        height: 50px;
        float: right;
        margin-right: 20px;
        line-height: 3px;
        padding-left: 0 !important;
        .seachContent {
          font-size: 18px;
          font-family: MicrosoftYaHei;
          font-weight: 400;
          line-height: 60px;
          margin: 0 0 0 -46px;
          color: rgba(51, 51, 51, 1);
        }
        .seachtitle {
          font-size: 12px;
          font-family: MicrosoftYaHei;
          font-weight: 400;
          color: rgba(102, 102, 102, 1);
        }
      }
    }
  }
  .infoNav-containner{
    width: 100%;
    height: 920px;
    font-size: 20px;
    color: #0072F3;
    background-color: #EFEFEF;

  }
  .viewContent{
    width: 100%;
    height: 840px;
    /*border: 1px solid red;*/
  }
  /*改变tab颜色*/
  .el-tabs__item:hover {
    color: #0072F3;
    cursor: pointer;
  }
  .el-tabs__item.is-active {
    color: #0072F3;
    background-color: #DCEDF1;
  }
  .el-tabs__active-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background-color: #0072F3;
    z-index: 1;
    -webkit-transition: -webkit-transform .3s cubic-bezier(.645,.045,.355,1);
    transition: -webkit-transform .3s cubic-bezier(.645,.045,.355,1);
    transition: transform .3s cubic-bezier(.645,.045,.355,1);
    transition: transform .3s cubic-bezier(.645,.045,.355,1), -webkit-transform .3s cubic-bezier(.645,.045,.355,1);
    transition: transform .3s cubic-bezier(.645,.045,.355,1),-webkit-transform .3s cubic-bezier(.645,.045,.355,1);
    list-style: none;
  }
  .el-tabs__item {
    padding: 0 20px;
    height: 40px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    line-height: 40px;
    display: inline-block;
    list-style: none;
    font-size: 14px;
    font-weight: 500;
    color: #303133;
    text-align: center;
    position: relative;
  }
  .el-tabs__item.is-top:last-child {
    padding-right: 18px;
  }
  /************告警样式*************/
  .alarmRow{
    width: 100%;
  }
  .alarmCol{
    width: 100%;
  }
  /***************Tab组件颜色修改*****************/
  /deep/ .el-tabs__item:hover{
    color: #0072F3;
  }
  /deep/ .el-tabs__item.is-active{
    color: #0072F3;
    line-height: 50px;
  }
  /deep/ .el-tabs__active-bar{
    height: 4px;
    background-color: #0072F3;
  }
  /deep/ .el-tabs__nav{
    margin-left: 30px;
    height: 45px;
  }
  /deep/ .el-tabs__nav-wrap{
    height: 50px;
  }
  /deep/ .el-tabs__nav-wrap::after{
    background-color: #EFEFEF;
  }
  /deep/ .el-tabs__header{
    margin: 0 0 5px;
  }
</style>
